package o;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Environment;
import android.os.StatFs;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import com.huawei.fastengine.BuildConfig;
import com.huawei.hms.adapter.internal.CommonCode.MapKey;
import com.huawei.hwCloudJs.d.d;
import java.io.UnsupportedEncodingException;
import java.net.NetworkInterface;
import java.util.Collections;
import org.json.JSONException;
import org.json.JSONObject;

public class foe {

    static final class a {
        private Intent ˋ;

        private a(Context context) {
            this.ˋ = context.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
        }

        private int ˋ() {
            return this.ˋ.getIntExtra("level", 0);
        }

        private int ˊ() {
            return this.ˋ.getIntExtra("scale", 0);
        }

        private int ॱ() {
            return this.ˋ.getIntExtra("voltage", 0);
        }

        private int ˏ() {
            return this.ˋ.getIntExtra("temperature", 0);
        }
    }

    public static void ˋ(Context context) {
    }

    public static String ॱ(Context context) {
        try {
            return new String(ˏ(context).getBytes(), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return "";
        }
    }

    private static String ˊ(Context context) {
        StringBuilder stringBuilder = new StringBuilder();
        Object packageName = context.getPackageName();
        String str = "ssosdk";
        if (!TextUtils.isEmpty(packageName) && packageName.contains("com.sina.weibo")) {
            str = "weibo";
        }
        stringBuilder.append(Build.MANUFACTURER).append("-").append(Build.MODEL);
        stringBuilder.append("__");
        stringBuilder.append(str);
        stringBuilder.append("__");
        try {
            stringBuilder.append(BuildConfig.VERSION_NAME.replaceAll("\\s+", "_"));
        } catch (Exception e) {
            stringBuilder.append(d.b);
        }
        stringBuilder.append("__").append("android").append("__android").append(VERSION.RELEASE);
        return stringBuilder.toString();
    }

    private static String ˏ(Context context) {
        JSONObject jSONObject = new JSONObject();
        try {
            CharSequence ˋ = ˋ();
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("os", ˋ);
            }
            ˋ = ʼ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("imei", ˋ);
            }
            ˋ = ᐝ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("meid", ˋ);
            }
            ˋ = ʻ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("imsi", ˋ);
            }
            ˋ = ʽ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("mac", ˋ);
            }
            ˋ = ॱॱ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("iccid", ˋ);
            }
            ˋ = ˊ();
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("serial", ˋ);
            }
            ˋ = ˋॱ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("androidid", ˋ);
            }
            ˋ = ˎ();
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("cpu", ˋ);
            }
            ˋ = ʽ();
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("model", ˋ);
            }
            ˋ = ʻ();
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("sdcard", ˋ);
            }
            ˋ = ͺ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put(MapKey.HAS_RESOLUTION, ˋ);
            }
            ˋ = ˏॱ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("ssid", ˋ);
            }
            ˋ = ˎ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("bssid", ˋ);
            }
            ˋ = ॱॱ();
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("deviceName", ˋ);
            }
            ˋ = ˊॱ(context);
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("connecttype", ˋ);
            }
            String str = "";
            try {
                ˋ = ˊ(context);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (!TextUtils.isEmpty(ˋ)) {
                jSONObject.put("ua", ˋ);
            }
            double ॱˊ = ॱˊ(context);
            jSONObject.put("batterymaxcapacity", String.valueOf(ॱˊ));
            jSONObject.put("batterycurrentcapacity", String.valueOf(ॱˊ));
            a aVar = new a(context);
            jSONObject.put("batterycurrentvoltage", aVar.ॱ());
            jSONObject.put("batterycurrenttemperature", aVar.ˏ());
            jSONObject.put("batterycurrentcapacity", (ॱˊ * ((double) aVar.ˋ())) / ((double) aVar.ˊ()));
            return jSONObject.toString();
        } catch (JSONException e2) {
            return "";
        }
    }

    private static String ˋ() {
        try {
            return "Android " + VERSION.RELEASE;
        } catch (Exception e) {
            return "";
        }
    }

    private static String ʼ(Context context) {
        try {
            return ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
        } catch (Exception e) {
            return "";
        }
    }

    private static String ᐝ(Context context) {
        try {
            return ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
        } catch (Exception e) {
            return "";
        }
    }

    private static String ʻ(Context context) {
        try {
            return ((TelephonyManager) context.getSystemService("phone")).getSubscriberId();
        } catch (Exception e) {
            return "";
        }
    }

    private static String ॱ() {
        try {
            for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
                if (networkInterface.getName().equalsIgnoreCase("wlan0")) {
                    byte[] hardwareAddress = networkInterface.getHardwareAddress();
                    if (hardwareAddress == null) {
                        return "";
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    int length = hardwareAddress.length;
                    for (int i = 0; i < length; i++) {
                        stringBuilder.append(String.format("%02X:", new Object[]{Byte.valueOf(hardwareAddress[i])}));
                    }
                    if (stringBuilder.length() > 0) {
                        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
                    }
                    return stringBuilder.toString();
                }
            }
        } catch (Exception e) {
        }
        return "";
    }

    private static String ʽ(Context context) {
        if (VERSION.SDK_INT >= 23) {
            return ॱ();
        }
        try {
            WifiManager wifiManager = (WifiManager) context.getSystemService(d.f);
            if (wifiManager == null) {
                return "";
            }
            WifiInfo connectionInfo = wifiManager.getConnectionInfo();
            return connectionInfo != null ? connectionInfo.getMacAddress() : "";
        } catch (Exception e) {
            return "";
        }
    }

    private static String ॱॱ(Context context) {
        try {
            return ((TelephonyManager) context.getSystemService("phone")).getSimSerialNumber();
        } catch (Exception e) {
            return "";
        }
    }

    private static String ˊ() {
        String str = "";
        if (VERSION.SDK_INT >= 26) {
            return ˏ();
        }
        try {
            Class cls = Class.forName("android.os.SystemProperties");
            return (String) cls.getMethod("get", new Class[]{String.class, String.class}).invoke(cls, new Object[]{"ro.serialno", d.b});
        } catch (Exception e) {
            return str;
        }
    }

    private static double ॱˊ(Context context) {
        Object obj = null;
        String str = "com.android.internal.os.PowerProfile";
        try {
            obj = Class.forName("com.android.internal.os.PowerProfile").getConstructor(new Class[]{Context.class}).newInstance(new Object[]{context});
        } catch (Exception e) {
        }
        try {
            return ((Double) Class.forName("com.android.internal.os.PowerProfile").getMethod("getAveragePower", new Class[]{String.class}).invoke(obj, new Object[]{"battery.capacity"})).doubleValue();
        } catch (Exception e2) {
            return 0.0d;
        }
    }

    @TargetApi(26)
    private static String ˏ() {
        String str = "";
        try {
            str = Build.getSerial();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }

    private static String ˋॱ(Context context) {
        try {
            return Secure.getString(context.getContentResolver(), "android_id");
        } catch (Exception e) {
            return "";
        }
    }

    private static String ˎ() {
        try {
            return Build.CPU_ABI;
        } catch (Exception e) {
            return "";
        }
    }

    private static String ʽ() {
        try {
            return Build.MODEL;
        } catch (Exception e) {
            return "";
        }
    }

    private static String ʻ() {
        try {
            StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
            return Long.toString(((long) statFs.getBlockCount()) * ((long) statFs.getBlockSize()));
        } catch (Exception e) {
            return "";
        }
    }

    private static String ͺ(Context context) {
        try {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
            return String.valueOf(displayMetrics.widthPixels) + "*" + String.valueOf(displayMetrics.heightPixels);
        } catch (Exception e) {
            return "";
        }
    }

    private static String ˏॱ(Context context) {
        try {
            WifiInfo connectionInfo = ((WifiManager) context.getApplicationContext().getSystemService(d.f)).getConnectionInfo();
            if (connectionInfo != null) {
                return connectionInfo.getSSID();
            }
        } catch (Exception e) {
        }
        return "";
    }

    public static String ˎ(Context context) {
        try {
            WifiInfo connectionInfo = ((WifiManager) context.getApplicationContext().getSystemService(d.f)).getConnectionInfo();
            if (connectionInfo != null) {
                return connectionInfo.getBSSID();
            }
        } catch (SecurityException e) {
        }
        return "";
    }

    private static String ॱॱ() {
        try {
            return Build.BRAND;
        } catch (Exception e) {
            return "";
        }
    }

    private static String ˊॱ(Context context) {
        String str = d.a;
        try {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null) {
                if (activeNetworkInfo.getType() == 0) {
                    switch (activeNetworkInfo.getSubtype()) {
                        case 1:
                        case 2:
                        case 4:
                        case 7:
                        case 11:
                            return "2G";
                        case 3:
                        case 5:
                        case 6:
                        case 8:
                        case 9:
                        case 10:
                        case 12:
                        case 14:
                        case 15:
                            return "3G";
                        case 13:
                            return "4G";
                        default:
                            return d.a;
                    }
                } else if (activeNetworkInfo.getType() == 1) {
                    return d.f;
                }
            }
            return str;
        } catch (Exception e) {
            return str;
        }
    }
}
